package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.AdviceAnswer;
import com.pgybook.db.entity.domain.AdviceAnswerEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface AdviceAnswerMapper {
    int countByExample(AdviceAnswerEx example);

    int deleteByExample(AdviceAnswerEx example);

    @Delete({
            "delete from adviceanswer",
            "where ANSWERID = #{answerid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer answerid);

    @Insert({
            "insert into adviceanswer (ADVICEID, CONTENT, ",
            "CRTTYPE, CUSTID, ",
            "STAFFID, CRTTIME)",
            "values (#{adviceid,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, ",
            "#{crttype,jdbcType=INTEGER}, #{custid,jdbcType=BIGINT}, ",
            "#{staffid,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "answerid", before = false, resultType = Integer.class)
    int insert(AdviceAnswer record);

    int insertSelective(AdviceAnswer record);

    List<AdviceAnswer> selectByExample(AdviceAnswerEx example);

    @Select({
            "select",
            "ANSWERID, ADVICEID, CONTENT, CRTTYPE, CUSTID, STAFFID, CRTTIME",
            "from adviceanswer",
            "where ANSWERID = #{answerid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    AdviceAnswer selectByPrimaryKey(Integer answerid);

    int updateByExampleSelective(@Param("record") AdviceAnswer record, @Param("example") AdviceAnswerEx example);

    int updateByExample(@Param("record") AdviceAnswer record, @Param("example") AdviceAnswerEx example);

    int updateByPrimaryKeySelective(AdviceAnswer record);

    @Update({
            "update adviceanswer",
            "set ADVICEID = #{adviceid,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=VARCHAR},",
            "CRTTYPE = #{crttype,jdbcType=INTEGER},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "STAFFID = #{staffid,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where ANSWERID = #{answerid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(AdviceAnswer record);
}
